<script type="text/javascript" src="<?php echo $this->baseUrl;?>/public/media/scripts/jquery/ui.datepicker.js"></script>
<link type="text/css" href="<?php echo $this->baseUrl;?>/public/media/css/flora.datepicker.css" rel="stylesheet"/>


<div id="titleTop" style="padding-top: 9px;">
	<div align="left">
		<?php if(!empty($this->errMsg)) :?>
			<?php $this->listError($this->errMsg,$this->lang_data); ?>
		<?php endif; ?>
	</div>
	<div class="titleTop-title"> <?php echo $this->lang_data->_('Add new account'); ?> </div>
	<div class="clearDiv"></div>
</div>

<div id="form">
<form action="<?php echo $this->baseUrl; ?>/backend/account/add" method="post">

	<input type="hidden" name="hidId" id="hidId" value="<?php echo $this->user->id; ?>"/>
	<input type="hidden" name="hidDate" id="hidDate" value="<?php echo $this->hidDate; ?>"/>

	<table width="100%" border="0" cellpadding="0" cellspacing="0">
	  <tr align="left">
		<td width="23"  class="form-header">&nbsp;</td>
		<td width="170" class="form-nameTitle"><?php echo $this->lang_data->_('User Detail'); ?></td>
		<td class="form-header">&nbsp;</td>
	  </tr>
	  <tr>
	  	<td class="form-row01">&nbsp; </td>
		<td class="form-name1"><?php echo $this->lang_data->_('User Name'); ?> :</td>
	    <td class="form-row01"><input type="text" class="textBox" name="username" id="username" value="" /></td>
	  </tr>
	  <tr>
	  	<td class="form-row02">&nbsp; </td>
		<td class="form-name2"><?php echo $this->lang_data->_('Password');?> :</td>
	    <td class="form-name2"><input type="password" class="textBox" name="password" id="password" value="" /></td>
	  </tr>
          <tr>
	  	<td class="form-row02">&nbsp; </td>
		<td class="form-name2"><?php echo $this->lang_data->_('Retype Password');?> :</td>
	    <td class="form-name2"><input type="password" class="textBox" name="repassword" id="repassword" value="" /></td>
	  </tr>
	  <tr>
	  	<td class="form-row01"> &nbsp;</td>
		<td class="form-name1"><?php echo $this->lang_data->_('Full Name'); ?> :</td>
	    <td class="form-row01"><input type="text" class="textBox" name="fullname" id="fullname" value="" /></td>
	  </tr>
          <tr>
	  	<td class="form-row01"> &nbsp;</td>
		<td class="form-name1"><?php echo $this->lang_data->_('Birthday'); ?> :</td>
                <td class="form-row01"><input type="text" class="textBox" name="birthday" id="birthday" value="" readonly/></td>
	  </tr>
          <tr>
	  	<td class="form-row01"> &nbsp;</td>
		<td class="form-name1"><?php echo $this->lang_data->_('Address'); ?> :</td>
	    <td class="form-row01"><input type="text" class="textBox" name="address" id="address" value="" /></td>
	  </tr>
          <tr>
	  	<td class="form-row01"> &nbsp;</td>
		<td class="form-name1"><?php echo $this->lang_data->_('Email'); ?> :</td>
	    <td class="form-row01"><input type="text" class="textBox" name="email" id="email" value="" /></td>
	  </tr>
          <tr>
	  	<td class="form-row01"> &nbsp;</td>
		<td class="form-name1"><?php echo $this->lang_data->_('Phone'); ?> :</td>
	    <td class="form-row01"><input type="text" class="textBox" name="phone" id="phone" value="" /></td>
	  </tr>
          <tr>
	   	<td class="form-row02">&nbsp; </td>
		<td class="form-name2"><?php echo $this->lang_data->_('Active') ;?> :</td>
	    <td class="form-row02">
                <input type="radio" name="active" id="radActive" value="1" checked/> <?php echo $this->lang_data->_('Yes'); ?>
	    	<input type="radio" name="active" id="radActive" value="0" /> <?php echo $this->lang_data->_('No'); ?>
            </td>
	  </tr>
	  <tr>
	   	<td class="form-row02">&nbsp; </td>
		<td class="form-name2"><?php echo $this->lang_data->_('Sex') ;?> :</td>
	    <td class="form-row02">
                <input type="radio" name="sex" id="sex" value="1" checked/> <?php echo $this->lang_data->_('Male'); ?>
	    	<input type="radio" name="sex" id="sex" value="0" /> <?php echo $this->lang_data->_('Female'); ?>
            </td>
	  </tr>
	  <tr>
	 	<td class="form-row01">&nbsp; </td>
		<td class="form-name1"></td>
	  	<td class="form-row01">
	  		<input type="submit" class="button" name="submit" id="submit" value="<?php print  $this->lang_data->_('OK'); ?>"/>
	  		<input type="reset"  class="button" name="reset"  id="reset"  value="<?php print  $this->lang_data->_('Reset'); ?>"/>
	  		<input type="button"  class="button" name="back"  id="back"  value="<?php print  $this->lang_data->_('Back'); ?>" onclick="window.location='<?php echo $this->baseUrl."/backend/account"; ?>'"/>
	  	</td>
	  </tr>
	</table>

</form>
</div>
<div class="clearDiv"> </div>
<div style="height: 30px;"></div>
<script type="text/javascript">
$(document).ready(function(){
   $('#birthday').datepicker({
                 dateFormat: "dd-mm-yy",
                   showOn: "both",
                   buttonImage: "<?php echo $this->baseUrl;?>/public/media/images/calendar.jpg",
                   buttonImageOnly: true,
                   yearRange: '1950:2010'
   });
});

$('#submit').click(function(){

    if (isWhitespace($('#username').val()))
    {
        alert("Tên đăng nhập không thể bỏ trống");
        return false;
    }
    else if(haveSpecialChars($('#username').val()))
    {
        alert("Tên đăng nhập không thể có ký tự đặc biệt");
        return false;
    }

    if (isWhitespace($('#password').val()))
    {
        alert("Mật khẩu không thể bỏ trống");
        return false;
    }
    else if(haveSpecialChars($('#password').val()))
    {
        alert("Mật khẩu không thể có ký tự đặc biệt");
        return false;
    }

    if($('#password').val() != $('#repassword').val())
    {
        alert("Mật khẩu xác nhận không khớp.");
        return false;
    }

    if (isWhitespace($('#fullname').val()))
    {
        alert("Họ tên không thể bỏ trống");
        return false;
    }
    else if(haveSpecialChars($('#fullname').val()))
    {
        alert("Họ tên không thể có ký tự đặc biệt");
        return false;
    }

    if (isWhitespace($('#birthday').val()))
    {
        alert("Ngày sinh không thể bỏ trống");
        return false;
    }

    if (isWhitespace($('#address').val()))
    {
        alert("Địa chỉ không thể bỏ trống");
        return false;
    }

    if (isWhitespace($('#email').val()))
    {
        alert("Email không thể bỏ trống");
        return false;
    }
    else if(isEmail($('#email').val()) == false)
    {
        alert("Email không đúng định dạng");
        return false;
    }
})
</script>